package com.itheima.health.h5.mq;

import com.itheima.health.utils.sms.SmsUtils;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @program: health_paret
 * @description:
 * @author: Mr.Wang
 * @create: 2020-11-14 09:35
 **/
@Component
public class Note {
    @RabbitListener(queues = "bocai1")//用来获取消息队列上的数据
    //map是要和传过来的参数类型一样
    public void email(Map<String, String> map) {
            //获得从消息队列中取得的map值
            Set<String> keySet = map.keySet();

            String telephone = map.get("telephone");
            String code = map.get("code");
        System.out.println("code = " + telephone);
            //发送验证码
            SmsUtils.validUserTelephone(telephone, code);
    }
}
